package cn.sdormitory.controller.forms;

import cn.sdormitory.basedata.entity.BStudent;
import cn.sdormitory.common.PageForm;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class FilterStudentQueryForm extends PageForm<FilterStudentQueryForm,BStudent> {
    private Integer classId;
    private String studentName;
    @Override
    public LambdaQueryWrapper<BStudent> lambdaQuery() {
        return super.lambdaQuery()
                .select(BStudent::getId,BStudent::getStudentNo,BStudent::getStudentName,
                        BStudent::getClassId,BStudent::getClassName,
                        BStudent::getStuPhoto,BStudent::getPhone)
                .eq(classId != null,BStudent::getClassId,classId)
                .eq(BStudent::getIsGraduated, "0")
                .isNotNull(classId == null,BStudent::getClassId)
                .like(studentName != null,BStudent::getStudentName,studentName);
    }
}
